<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>layout后台布局 - Layui</title>
<link rel="stylesheet" href="../layui/css/layui.css">
<link rel="stylesheet" href="../css/newedit.css">
</head>
<body>
<div class="max_div">  
<h2>分类添加界面</h2>
<?php
    try{
         $pdo = new PDO("mysql:host=localhost;dbname=boke","root","root"); 
       }
       catch(PDOException $e){
        echo "数据库连接失败:".$e->getMessage();
        exit;
      }
       $tr=$pdo->query("select * from article_kind");
       $str=$tr->fetchALL(PDO::FETCH_ASSOC);
?>
<table class="table table-hover" id="list" style="width:800px;margin:0 auto">          
  <tr>
      <th width="145">ID值</th>
      <th width="45">类名</th>
      <th width="200">分类代号</th>
      <th width="">类描述</th>
      <th width="200">操  作</th>
  </tr>  
<?php 
foreach($str as $v){
?>
  <tr>
      <th width="145"><?php echo $v["id"]?></th>
      <th width="45"><?php echo $v["king"]?></th>
      <th width="200"><?php echo $v["kid"]?></th>
      <th width=""><?php echo $v["explanation"]?></th>  
      <th width="">
        <a class="del-btn" href="javascript:void(0);" data-id="<?php echo $v["id"]?>">删除</a>
        <a href="addkid.php"> 添加</a>
      </th>
  </tr>
  <?php
   }
  ?>
</table>
</div>
</body>
</html>
<script src="../layui/layui.js"></script>
<script>
layui.use(['form', 'layedit', 'laydate','jquery'], function(){
  var form = layui.form()
  ,layer   = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate
  ,$       = layui.jquery;
  
  //创建一个编辑器
  var editIndex = layedit.build('LAY_demo_editor');


 $(".del-btn").click(function(){
    var  flag=confirm("确认要删除吗/删除后分类下的所有文章将全部清空");
   var  id=$(this).data('id');
  if(flag){

    // alert(id);
  $.ajax(){
    url:"do/do_delekid.php",
    async:true,
    type:"post",
    dete:{"id":id},
       dataType:"json",
       success:function(msg){
         if(msg.errno==1){
         window.location.href = "index.php";
         }
         else{
        window.location.href = "dele.php";
         }
       },
     }
 }
  
}

 })
   




})



</script>